<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	Integer totlenum = (Integer) session.getAttribute("totlenum");
	Integer curPage = (Integer) session.getAttribute("curPage");
	String cardno = (String) session.getAttribute("cardno");
	String cardnoFrom = (String) session.getAttribute("cardnoFrom");
	String cardnoTo = (String) session.getAttribute("cardnoTo");
	Integer money = (Integer) session.getAttribute("money");
	String parentid = (String) session.getAttribute("parentid");
	Integer status = (Integer) session.getAttribute("status");
	Integer termofvalidity = (Integer) session.getAttribute("termofvalidity");
	Integer probationperiod = (Integer) session.getAttribute("probationperiod");
	String batch = (String) session.getAttribute("batch");
	String mobile = (String) session.getAttribute("mobile");
	String freeroute = (String) session.getAttribute("freeroute");
	String parent = (String) session.getAttribute("parent");
	String adminUserId = (String) session.getAttribute("adminUserId");
	Integer adminUsergrade = (Integer) session.getAttribute("adminUsergrade");
	Integer cardnum = (Integer) session.getAttribute("cardnum");
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>CMS系统</title>
<script type="text/javascript" src="<%=basePath%>js/initPage.js"></script>
<!-- Bootstrap -->
<link href="<%=basePath%>vendors/bootstrap/dist/css/bootstrap.min.css"
	rel="stylesheet">
<!-- Font Awesome -->
<link
	href="//netdna.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
	rel="stylesheet">
<!-- NProgress -->
<link href="<%=basePath%>vendors/nprogress/nprogress.css"
	rel="stylesheet">
<!-- iCheck -->
<link href="<%=basePath%>vendors/iCheck/skins/flat/green.css"
	rel="stylesheet">

<!-- bootstrap-progressbar -->
<link
	href="<%=basePath%>vendors/bootstrap-progressbar/css/bootstrap-progressbar-3.3.4.min.css"
	rel="stylesheet">
<!-- JQVMap -->
<link href="<%=basePath%>vendors/jqvmap/dist/jqvmap.min.css"
	rel="stylesheet" />
<!-- bootstrap-daterangepicker -->
<link
	href="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.css"
	rel="stylesheet">

<!-- Custom Theme Style -->
<link href="<%=basePath%>build/css/custom.min.css" rel="stylesheet">
</head>

<body class="nav-md">
	<div id="huabodiv" class="white_content_small">
		<div style="text-align: right; cursor: default; height: 40px;">
			<span style="font-size: 16px;" onclick="CloseDiv('huabodiv','fade')">关闭</span>
		</div>
		
		<!--  <div style="display: flex;flex-direction: row;justify-content: space-between;
		    cursor: default; height: 40px;">
		    <span style="font-size: 12px;color:#ff0033">请根据卡号/卡号段/批次号/所属商进行批量修改，如根据所属商，将修改该所属商的所有卡的信息</span>
			<span style="font-size: 16px;" onclick="CloseDiv('huabodiv','fade')">关闭</span>
		</div>-->
		
		<div class="item form-group">
			使用有效期<input id="probationperiod" class="form-control col-md-7 col-xs-12"
				name="name" placeholder="如：365" type="text" value="${probationperiod}">
		</div>
		<div class="item form-group">
			修改充值前有效期<input id="termofvalidity" class="form-control col-md-7 col-xs-12"
				name="name" placeholder="如：365" type="text" value="${termofvalidity}">
		</div><div class="item form-group">
			延长充值前有效期<input id="addtermofvalidity" class="form-control col-md-7 col-xs-12"
				name="name" placeholder="如：365" type="text" value="">
		</div>
		<div class="item form-group">
			充值卡金额<input id="money" class="form-control col-md-7 col-xs-12"
				name="name" placeholder="" type="text" value="${money}">
		</div>
		<div class="item form-group" id="shopmoney_box" style="display: none">
			购物金金额<input id="shopmoney" class="form-control col-md-7 col-xs-12"
						name="name" placeholder="" type="text" value="${shopmoney}">
		</div>
		<div class="item form-group">
			充值修改商家 <select class="form-control" id="isupdateshop"
						 class="form-control col-md-7 col-xs-12">
				<option value="" selected="selected">请选择是否可修改</option>
				<option value="1">允许</option>
				<option value="0">不允许</option>
		    </select>
		</div>
		<div class="item form-group">
			费率 <select class="form-control" id="freeroute"
				class="form-control col-md-7 col-xs-12">
				<option value="" selected="selected">请选择修改的费率</option>
				<c:forEach items="${freeroutes}" var="s" varStatus="z">
					<option value="${s.name}">${s.name}</option>
				</c:forEach>
			</select>
		</div>
		<div class="item form-group">
			是否冻结 <select class="form-control" id="datastatus"
				class="form-control col-md-7 col-xs-12">
				<option value="" selected="selected">请选择修改的状态</option>
				<option value="true">使用</option>
				<option value="false">不使用</option>
			</select>
		</div>
		<div class="form-group">
			<div class="col-md-6 col-md-offset-3">
				<a type="submit" class="btn btn-primary" href="javascript:void(0)"
					onclick="CloseDiv('huabodiv','fade')">取消</a> <a id="dialog"
					type="submit" class="btn btn-success" href="javascript:void(0)"
					onclick="xiugaiall() ">批量修改</a>
			</div>
		</div>
	</div>


	<div class="container body">
		<div class="main_container">
			<div class="col-md-3 left_col">
				<div class="left_col scroll-view">

					<div class="clearfix"></div>



					<br />




				</div>
			</div>



			<!-- page content -->
			<div class="right_col" role="main">
				<div class="">
					<div class="page-title">
					<span style="font-size: 12px;color:#ff0033;display: none" id="prompt">请根据卡号/卡号段/批次号/所属商进行批量修改，
					               如根据所属商，将修改该所属商的所有卡的信息</span>
					</div>
					<div class="x_content">
						<div class="x_content">
						   <c:if test="${datastatus != 0 && datastatus != 1 && datastatus != 2}">
						    <select class="btn btn-default dropdown-toggle" id="data" style="text-align: center;">
								<option value="3" selected="selected" >状态</option>
								<option value="0"> 全部</option>
								<option value="1">正常</option>
								<option value="2">冻结</option>
							</select>
							</c:if>
						    <c:if test="${datastatus == 0}">
						    <select class="btn btn-default dropdown-toggle" id="data" style="text-align: center;">
								<option value="3">状态</option>
								<option value="0" selected="selected" > 全部</option>
								<option value="1">正常</option>
								<option value="2">冻结</option>
							</select>
							</c:if>
							<c:if test="${datastatus == 1}">
						    <select class="btn btn-default dropdown-toggle" id="data" style="text-align: center;">
								<option value="3">状态</option>
								<option value="0"> 全部</option>
								<option value="1" selected="selected" >正常</option>
								<option value="2">冻结</option>
							</select>
							</c:if>
							<c:if test="${datastatus == 2}">
						    <select class="btn btn-default dropdown-toggle" id="data" style="text-align: center;">
								<option value="3">状态</option>
								<option value="0"> 全部</option>
								<option value="1">正常</option>
								<option value="2" selected="selected" >冻结</option>
							</select>
							</c:if>
							<c:if test="${status != 0 && status != 1 &&status != 2}">
						    <select class="btn btn-default dropdown-toggle" id="status" style="text-align: center;">
								<option value="3" selected="selected" >充值状态</option>
								<option value="0"> 全部</option>
								<option value="1">未使用</option>
								<option value="2">已充值</option>
							</select>
						    </c:if>
						    <c:if test="${status == 0}">
						    <select class="btn btn-default dropdown-toggle" id="status" style="text-align: center;">
								<option value="3">充值状态</option>
								<option value="0" selected="selected" > 全部</option>
								<option value="1">未使用</option>
								<option value="2">已充值</option>
							</select>
						    </c:if>
						    <c:if test="${status == 1}">
						    <select class="btn btn-default dropdown-toggle" id="status" style="text-align: center;">
								<option value="3">充值状态</option>
								<option value="0"> 全部</option>
								<option value="1" selected="selected" >未使用</option>
								<option value="2">已充值</option>
							</select>
						    </c:if>
						    <c:if test="${status == 2}">
						    <select class="btn btn-default dropdown-toggle" id="status" style="text-align: center;">
								<option value="3">充值状态</option>
								<option value="0"> 全部</option>
								<option value="1">未使用</option>
								<option value="2" selected="selected" >已充值</option>
							</select>
						    </c:if>
						      <select class="btn btn-default dropdown-toggle" id="type" style="text-align: center;">
								<option value="10" <c:if test="${type == 10}">selected</c:if>>种类</option>
								<option value="0" <c:if test="${type == 0}">selected</c:if>> 全部</option>
								<option value="1" <c:if test="${type == 1}">selected</c:if>>月卡</option>
								<option value="2" <c:if test="${type == 2}">selected</c:if>>季卡</option>
								<option value="3" <c:if test="${type == 3}">selected</c:if>>年卡</option>
								<option value="4" <c:if test="${type == 4}">selected</c:if>>面值卡</option>
								<option value="5" <c:if test="${type == 5}">selected</c:if>>购物卡</option>
								<option value="6" <c:if test="${type == 6}">selected</c:if>>等值卡</option>
								<option value="7" <c:if test="${type == 7}">selected</c:if>>自定义卡</option>
								<option value="8" <c:if test="${type == 8}">selected</c:if>>挪车卡</option>
							</select>
							批次: <input type="text" name="lname" id="batch" value="${batch}" />
							面值: <input type="number" name="lname" id="input_money"
								value="${money}" /> 充值电话 : <input type="text" name="lname"
								id="mobile" value="${mobile}" />
						</div>
						<p>
						           所属账户名: <input type="text"
								name="lname" id="parentid" value="${parentid}" />
							卡号: <input type="text" name="lname" id="cardno" value="${cardno}" />
							有效期: <input type="number" name="lname" id="termofvaliditySel"
								value="${termofvalidity}" /> 使用有效期: <input type="number"
								name="lname" id="probationperiodSel" value="${probationperiod}" />
						</p>

						<p>
							<select class="btn btn-default dropdown-toggle" id="feelroute" style="text-align: center;">
									<option value="" <c:if test="${feelroute == null}">selected </c:if>>费率</option>
									<c:forEach items="${freeroutes}" var="s" varStatus="z">
											<option value="${s.name}" <c:if test="${feelroute == s.name}">selected </c:if>>${s.name}</option>
									</c:forEach>
							</select>					
							卡号段查询: <input type="text" name="lname" id="cardnoFrom"
								value="${cardnoFrom}" /> —— <input type="text" name="lname"
								id="cardnoTo" value="${cardnoTo}" />
							<button type="submit" class="btn btn-default"
								onclick="selectOEM('${curPage}')">搜索</button>
						</p>
						<p>
						    <c:if test="${adminUsergrade < 2 }">
								<button id="info" class="btn btn-default" >导入</button>
							</c:if>
							<c:if test="${adminUsergrade < 3 }">
								<button id="export" class="btn btn-default" onclick="daochu()">导出</button>
							</c:if>
							<c:if test="${adminUsergrade < 3 }">	
								<button type="submit" class="btn btn-default"
									onclick="jumpTohuabo()">划拨</button>
							</c:if>
							<c:if test="${adminUsergrade < 2 }">	
								<button type="submit" class="btn btn-default"
									onclick="jumpTohuishou()">回收</button>
							</c:if>
							<c:if test="${adminUsergrade == 1 }">
								<button id="qrcode" class="btn btn-default"
									onclick="createQRCode()">导出二维码</button>
							</c:if>
							<c:if test="${adminUsergrade < 2 }">
								<button type="submit" class="btn btn-default" id="update"
									onclick="ShowDiv('huabodiv','fade')">批量修改查询结果</button>
							</c:if>
							<a>共计${totlenum }张</a>
								<c:if test="${adminUsergrade < 1 }">
								<a>卡号段从${minCardNo }到 ${maxCardNo } </a>
								</c:if>
							<form name="myForm" class="form-horizontal form-label-left" novalidate 
		                          method= "post" enctype ="multipart/form-data" id="formUpload" 
		                          style="display: none">
		                          <input class="form-control col-md-7 col-xs-12"
		                          id="file" name="file" required="required" type="file"
		                          placeholder="请先上传excel" form="formUpload">
		                          <input id="agentlogo" name="agentlogo" class="form-control col-md-7 col-xs-12"
		                          style="display:none" type="text" value="">
		                    <a id="upload" type="submit" class="btn btn-success"  
		                       href="javascript:void(0)" onclick="">上传</a>
		                    </form> 
						</p>
					</div>
					<div class="row">
						<div class="col-md-12 col-sm-12 col-xs-12">
							<div class="x_panel">
								<div class="x_title">

									<div class="clearfix"></div>
								</div>
								<div class="x_content">
									<input type="hidden" name="parent" id="parent"
										value="${parent}" /> <input type="hidden" name="parent"
										id="adminUserId" value="${adminUserId}" />


									<table id="datatable"
										class="table table-striped table-bordered">

										<thead>
											<tr>
												<th><input type="checkbox" id="checkall"
													name="checkall" onclick="checkAll()" />全选</th>
												<th>卡号</th>
												<th>卡密</th>
												<th>使用有效期</th>
												<th>开卡时间</th>
												<th>充值前有效期</th>
												<th>批次</th>
												<th>面值</th>
												<th>购物金</th>
												<th>费率组</th>
												<th>充值卡类型</th>
												<th>充值号码</th>
												<th>所属商</th>
												<th>状态</th>
											</tr>
										</thead>

										<tbody>
											<c:forEach items="${list}" var="s" varStatus="z">
												<tr>
													<td><input type="checkbox" value="${s.id}" id="check"
														name="check" /></td>
													<td id="sid">${s.cardno}</td>
													<td>${s.pwd}</td>
													<td>${s.probationperiod}</td>
													<td><fmt:formatDate value="${s.createtime}" type="date"
													        pattern="yyyy-MM-dd" /></td>
													<td><fmt:formatDate value="${s.endtime}" type="date"
													        pattern="yyyy-MM-dd" /></td>
													<td>${s.batch}</td>
													<td>${s.money}</td>
													<td>${s.shopmoney}</td>
													<td>${s.feelroute}</td>
													<td><c:if test="${s.type == 1 }">
															<span>月卡</span>
														</c:if> <c:if test="${s.type == 2 }">
															<span>季卡</span>
														</c:if> <c:if test="${s.type == 3 }">
															<span>年卡</span>
														</c:if> <c:if test="${s.type == 4 }">
															<span>面值卡</span>
														</c:if> <c:if test="${s.type == 5 }">
															<span>购物卡</span>
														</c:if> <c:if test="${s.type == 6 }">
															<span>等值卡</span>
														</c:if><c:if test="${s.type == 7 }">
															<span>自定义卡</span>
														</c:if><c:if test="${s.type == 8 }">
														    <span>挪车卡</span>
														</c:if></td>
													<td><c:if test="${s.mobile == null ||s.mobile ==''}">
															<span>该卡暂未充值</span>
														</c:if> <c:if test="${s.mobile != null }">
															<span>${s.mobile}</span>
														</c:if></td>
													<td>${s.users.username}</td>
													<td><c:if test="${s.datastatus == true}">
															<span>可用</span>
														</c:if> <c:if test="${s.datastatus == false }">
															<span>冻结</span>
														</c:if></td>
												</tr>

											</c:forEach>

										</tbody>
									</table>
								</div>
							</div>
						</div>
					</div>
				</div>
				<div style="width: 100%;text-align: center;">
					<div id='page'></div>
				</div>
			</div>
			<!-- /page content -->


		</div>
	</div>
	<script>
				/**
				 * 纯粹的JS分页插件，代码缺点：JS操作DOM冗余太多，太繁琐
				 */
				pageUtil.initPage('page', {
					totalCount : ${totlenum}, //总页数，一般从回调函数中获取。如果没有数据则默认为1页
					curPage : ${curPage}, //初始化时的默认选中页，默认第一页。如果所填范围溢出或者非数字或者数字字符串，则默认第一页
					showCount : 9, //分页栏显示的数量
					pageSizeList : [ 10 ], //自定义分页数，默认[5,10,15,20,50]
					defaultPageSize : 10, //默认选中的分页数,默认选中第一个。如果未匹配到数组或者默认数组中，则也为第一个
					isJump : true, //是否包含跳转功能，默认false
					isPageNum : true, //是否显示分页下拉选择，默认false
					isPN : true, //是否显示上一页和下一面，默认true
					isFL : true, //是否显示首页和末页，默认true
					jump : function(curPage, pageSize) { //跳转功能回调，传递回来2个参数，当前页和每页大小。如果没有设置分页下拉，则第二个参数永远为0。这里的this被指定为一个空对象，如果回调中需用到this请自行使用bind方法
						selectOEM(curPage);
					},
				});
			</script>

	<style>
.black_overlay {
	display: none;
	position: absolute;
	top: 0%;
	left: 0%;
	width: 100%;
	height: 100%;
	background-color: black;
	z-index: 1001;
	-moz-opacity: 0.8;
	opacity: .80;
	filter: alpha(opacity = 80);
}

.white_content {
	display: none;
	position: absolute;
	top: 20%;
	left: 30%;
	width: 60%;
	height: 60%;
	border: 16px solid white;
	background-color: white;
	z-index: 1002;
	overflow: auto;
	left: 30%;
}

.white_content_small {
	display: none;
	position: absolute;
	top: 40%;
	left: 40%;
	width: 40%;
	height: 40%;
	border: 16px solid white;
	background-color: white;
	z-index: 1002;
	overflow: auto;
}
</style>
	<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
	<script src="<%=basePath%>vendors/download.js"></script>
	<script type="text/javascript">
	$('#upload').click(function() {
		
		var file = document.myForm.file.files[0];

		if (file != null || file != undefined) {

			var fileName = file.name.substring(file.name.lastIndexOf(".")+1).toLowerCase();
			
			if(fileName !="txt" && fileName !="xls" && fileName !="xlsx"){
				alert("只能上传 .txt,.xls,.xlsx类型的文件!");
	            return;
			}

			var fm = new FormData();

			fm.append('file', file);

			$.ajax(
				{
					url : "<%=basePath%>apiTest/uploadExcel",
					type : 'POST',
					data : fm,
					contentType : false, //禁止设置请求类型
					processData : false, //禁止jquery对DAta数据的处理,默认会处理
					//禁止的原因是,FormData已经帮我们做了处理
					success : function(result) {
						//测试是否成功
						//但需要你后端有返回值
						if(fileName == "txt"){
                            daoruTxt(result.json);
						}else{
                            daoruExcel(result.json);
						}
					}
				}
			);
		} else {
            if(fileName == "txt"){
                daoruTxt(null);
            }else{
                daoruExcel(null);
            }
		}
	});	
	</script>
	<script>
	    $("#update").mouseover(function(){
		    $("#prompt").css("display","block");
		});
	    $("#update").mouseout(function(){
		    $("#prompt").css("display","none");
		});
	    
	    $(document).ready(function(e) {
			$("#info").click(function(){
			    $("#formUpload").toggle();
			});
		});
	</script>
	<script type="text/javascript">
		//搜索 choose = 1
		function selectOEM(curPage) {
			var cardno = $("#cardno").val();
			var cardnoFrom = $("#cardnoFrom").val();
			var cardnoTo = $("#cardnoTo").val();
			var money = $("#input_money").val();
			var parentid = $("#parentid").val();
			var termofvaliditySel = $("#termofvaliditySel").val();
			var probationperiodSel = $("#probationperiodSel").val();
			var status = $("#status").find("option:selected").val();
			var data = $("#data").find("option:selected").val();
			var type = $("#type").find("option:selected").val();
			var batch = $("#batch").val();
			var mobile = $("#mobile").val();
			var feelroute = $("#feelroute").find("option:selected").val();
			location.href = "selectChongzhika?curPage="
				+ curPage +
				"&money=" + money +
				"&parentid=" + parentid +
				"&termofvalidity=" + termofvaliditySel +
				"&probationperiod=" + probationperiodSel +
				"&batch=" + batch +
				"&mobile=" + mobile +
				"&cardno=" + cardno +
				"&cardnoFrom=" + cardnoFrom +
				"&cardnoTo=" + cardnoTo +
				"&type=" + type +
				"&datastatus=" + data +
				"&feelroute=" + feelroute +
				"&status=" + status;
		}
	
		function jumpTohuabo() {
			var choose = 1;
			location.href = "content_huabo?choose=" + choose;
		}
	
		function jumpTohuishou() {
			var choose = 2;
			location.href = "content_huabo?choose=" + choose;
		}
	
		// ajax 对象
		function ajaxObject() {
			var xmlHttp;
			try {
				// Firefox, Opera 8.0+, Safari
				xmlHttp = new XMLHttpRequest();
			} catch (e) {
				// Internet Explorer
				try {
					xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
				} catch (e) {
					try {
						xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
					} catch (e) {
						alert("您的浏览器不支持AJAX！");
						return false;
					}
				}
			}
			return xmlHttp;
		}
	
		//全选
		function checkAll() {
			var all = document.getElementById('checkall'); //获取到点击全选的那个复选框的id  
			var one = document.getElementsByName('check'); //获取到复选框的名称  
			if (all.checked == true) { //因为获得的是数组，所以要循环 为每一个checked赋值  
				for (var i = 0; i < one.length; i++) {
					one[i].checked = true;
				}
	
			} else {
				for (var j = 0; j < one.length; j++) {
					one[j].checked = false;
				}
			}
		}
	
		function ajaxPost() {
			var id = $("#id").val();
			var cardnoFrom = $("#cardnoFrom").val();
			var cardnoTo = $("#cardnoTo").val();
			var batch = $("#batch").val();
			var parentid = $("#parent").val();
			var choose = 2;
			var ajax = ajaxObject();
			ajax.open("post", "updateCardsByJDBC?parentid=" + parentid +
				"&id=" + id +
				"&cardnoFrom=" + cardnoFrom +
				"&cardnoTo=" + cardnoTo +
				"&batch=" + batch +
				"&choose=" + choose, false);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						var result = ajax.responseText;
						if (result == "success") {
							//请求成功
							alert("回收成功");
							location.href = "content_chongzhikaguanli";
						} else {
							//创建失败
							alert(result);
						}
					} else {
						//请求失败
						alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
					}
				} else {
				}
			};
			ajax.send();
		}
	
		function xiugai(id) {
			var probationperiod = $("#probationperiod").val();
			var termofvalidity = $("#termofvalidity").val();
			var money = $("#money").val();
			var datastatus = $("#datastatus").find("option:selected").val();
			var freeroute = $("#freeroute").find("option:selected").val();
			var ajax = ajaxObject();
			ajax.open("post", "updateCards?id=" + id +
				"&datastatus=" + datastatus +
				"&probationperiod=" + probationperiod +
				"&termofvalidity=" + termofvalidity +
				"&money=" + money +
				"&feelroute=" + freeroute, true);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						var result = ajax.responseText;
						if (result == "success") {
	
							//请求成功
						} else {
							//创建失败
							alert(result);
						}
					} else {
						//请求失败
						alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
					}
				} else {
				}
			};
			ajax.send();
		}
		
		//根据卡段/批次号修改
		function xiugaiall() {
			var cardnoFrom = $("#cardnoFrom").val();
			var cardnoTo = $("#cardnoTo").val();
			var batch = $("#batch").val();
			var parentid = $("#parentid").val();
			var cardno = $("#cardno").val();
			var termofvalidity = $("#termofvalidity").val();
			var addtermofvalidity = $("#addtermofvalidity").val();
			var probationperiod = $("#probationperiod").val();
			var money = $("#money").val();
			var shopmoney = $("#shopmoney").val();
			if (shopmoney == null || shopmoney == "" || shopmoney == undefined){
				shopmoney = "";
			}
			var datastatus = $("#datastatus").find("option:selected").val();
			var freeroute = $("#freeroute").find("option:selected").val();
            var isupdateshop = $("#isupdateshop").find("option:selected").val();
			var ajax = ajaxObject();
			ajax.open("post", "xiugaiCardsByJDBC?datastatus=" + datastatus +
				"&termofvalidity=" + termofvalidity +
				"&addtermofvalidity=" + addtermofvalidity +
				"&probationperiod=" + probationperiod +
				"&money=" + money +
				"&shopmoney=" + shopmoney +
				"&feelroute=" + freeroute +
				"&cardnoFrom=" + cardnoFrom +
				"&cardnoTo=" + cardnoTo +
                "&isupdateshop=" + isupdateshop +
				"&parentid=" + parentid +
				"&cardno=" + cardno +
				"&batch=" + batch, false);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						var result = ajax.responseText;
						if (result == "success") {
	       
							//请求成功
						} else {
							//创建失败
							alert(result);
							selectOEM(${curPage});
						}
					} else {
						//请求失败
						alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
					}
				} else {
				}
			};
			ajax.send();
		}
	
	
		//选择批量修改
		function xiugaiAll() {
			var id = document.getElementsByName('check');
			var choose = 0;
			for (var i = 0; i < id.length; i++) {
				if (id[i].checked) {
					xiugai(id[i].value);
					choose = 1;
				}
			}
			if (choose == 1) {
				alert("所选账号已修改,正在刷新页面");
				location.href = "content_chongzhikaguanli";
			} else {
				alert("请选择需修改账号");
			}
		}
	
		//弹出隐藏层
		function ShowDiv(show_div, bg_div) {
			document.getElementById("shopmoney_box").style.display=(batch.value != null && batch.value != "")?"":"none";
			document.getElementById(show_div).style.display = 'block';
			document.getElementById(bg_div).style.display = 'block' ;
			var bgdiv = document.getElementById(bg_div);
			bgdiv.style.width = document.body.scrollWidth;
			// bgdiv.style.height = $(document).height();
			$("#" + bg_div).height($(document).height());
		}
        //关闭弹出层
		function CloseDiv(show_div, bg_div) {
			document.getElementById(show_div).style.display = 'none';
			document.getElementById(bg_div).style.display = 'none';
		}
        function daochu() {
			alert("正在导出中，请稍后……");
            $("#export").attr("disabled", "disabled");
			var cardno = $("#cardno").val();
			var cardnoFrom = $("#cardnoFrom").val();
			var cardnoTo = $("#cardnoTo").val();
			var money = $("#money").val();
			var parentid = $("#parentid").val();
			var batch = $("#batch").val();
			var mobile = $("#mobile").val();
			var adminUserId = $("#adminUserId").val();
			var ajax = ajaxObject();
			ajax.open("post", "<%=basePath%>apiTest/export?adminUserId=" + adminUserId +
				"&cardno=" + cardno +
				"&cardnoFrom=" + cardnoFrom +
				"&cardnoTo=" + cardnoTo +
				"&money=" + money +
				"&parentid=" + parentid +
				"&money=" + money +
				"&batch=" + batch +
				"&mobile=" + mobile, true);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						var result = JSON.parse(ajax.responseText);
                        $("#export").removeAttr("disabled");
                        if(result.headPath == "1"){
                            window.open("http://"+ result.fileName);
						}
						if(result.headPath == "2"){
                            window.open("https://"+ result.fileName);
						}
                        if(result.headPath == "3"){
                            alert("域名错误！");
                        }
					} else {
						//请求失败
						alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
					}
				} else {
				}
			};
			ajax.send();
		}
		
		function daoruTxt(file) {
			alert(file);
			var url = encodeURIComponent(file);
			var ajax = ajaxObject();
			ajax.open("post", "allCardsInfo?file=" + url, false);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						var result = ajax.responseText;
						var url = result.split(",");
						alert(url[0]+","+url[1]+","+url[2]);
						window.open("http://"+ url[3]);
						selectOEM(${curPage});
					} else {
						//请求失败
						selectOEM(${curPage});
					}
				} else {
				}
			};
			ajax.send();
		}

        function daoruExcel(file) {
            alert(file);
            var url = encodeURIComponent(file);
            var ajax = ajaxObject();
            ajax.open("post", "excelCardsInfo?file=" + url, false);
            ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            ajax.onreadystatechange = function() {
                if (ajax.readyState == 4) {
                    if (ajax.status == 200) {
                        var result = ajax.responseText;
                        var url = result.split(",");
                        alert(url[0]+","+url[1]+","+url[2]);
                        window.open("http://"+ url[3]);
                        selectOEM(${curPage});
                    } else {
                        //请求失败
                        selectOEM(${curPage});
                    }
                } else {
                }
            };
            ajax.send();
        }

        // 生成导出二维码
		function createQRCode() {
			alert("正在生成中，请稍后……");
			$("#qrcode").attr("disabled", "disabled");
			var cardnoFrom = $("#cardnoFrom").val();
			var cardnoTo = $("#cardnoTo").val();
			var ajax = ajaxObject();
			ajax.open("post", "<%=basePath%>carPack/getQRCode?cardnoFrom=" + cardnoFrom + "&cardnoTo=" + cardnoTo, true);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						$("#qrcode").removeAttr("disabled");
						var json = JSON.parse(ajax.responseText);
						switch (json.flag) {
							case -1:
								if(confirm(json.states)){
									location.href = "wx_allocations_index";
								}
								break;
							case -2:
								alert(json.states);
								break;
							case 1:
								downloadQRCode();
								break;
						}
					} else {
						//请求失败
						alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
					}
				} else {
				}
			};
			ajax.send();
		}

		function downloadQRCode() {
			alert("生成中完成，正在导出中，请稍后……");
			var cardnoFrom = $("#cardnoFrom").val();
			var cardnoTo = $("#cardnoTo").val();
			var ajax = ajaxObject();
			ajax.open("post", "<%=basePath%>carPack/exportNewCarPack?cardnoFrom=" + cardnoFrom + "&cardnoTo=" + cardnoTo, true);
			ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
			ajax.onreadystatechange = function() {
				if (ajax.readyState == 4) {
					if (ajax.status == 200) {
						var result = JSON.parse(ajax.responseText);
						if(result.headPath == "1"){
							window.open("http://"+ result.fileName);
						}
						if(result.headPath == "2"){
							window.open("https://"+ result.fileName);
						}
						if(result.headPath == "3"){
							alert("域名错误或未找到相关日期文件夹！");
						}
					} else {
						//请求失败
						alert("请求终止，请检查操作或联系客服咨询" + ajax.status);
					}
				} else {
				}
			};
			ajax.send();
		}
	</script>
	<!-- jQuery -->
	<script src="<%=basePath%>vendors/jquery/dist/jquery.min.js"></script>
	<!-- Bootstrap -->
	<script src="<%=basePath%>vendors/bootstrap/dist/js/bootstrap.min.js"></script>
	<!-- FastClick -->
	<script src="<%=basePath%>vendors/fastclick/lib/fastclick.js"></script>
	<!-- NProgress -->
	<script src="<%=basePath%>vendors/nprogress/nprogress.js"></script>
	<!-- bootstrap-daterangepicker -->
	<script src="<%=basePath%>vendors/moment/min/moment.min.js"></script>
	<script
		src="<%=basePath%>vendors/bootstrap-daterangepicker/daterangepicker.js"></script>
	<!-- Chart.js -->
	<script src="<%=basePath%>vendors/Chart.js/dist/Chart.min.js"></script>

	<!-- Custom Theme Scripts -->
	<script src="<%=basePath%>build/js/custom.min.js"></script>

	<script src="<%=basePath%>vendors/download.js"></script>

</body>
</html>